package hz.mobileproject.pda.network;

import java.io.File;

import hz.mobileproject.pda.entity.request.Request_Edu_inter;
import hz.mobileproject.pda.listener.CustomNetCallBack;
import hz.mobileproject.pda.utils.HttpRqUtils;

/**
 * Created by hasee on 2017/10/17.
 */

public class UploadNetWork {

    private final static String TAG = UploadNetWork.class.getSimpleName();
    private Request_Edu_inter mInter;


    public void uploadData(Request_Edu_inter inter){
        mInter = inter;
        //上传教育谈话
        File upFile = new File(inter.getFilePath());
        HttpRqUtils.httpPost(Constance.BASE_URL + Constance.URL_EDUTALK_INSERT_EDU, mInter, upFile, new CustomNetCallBack() {
            @Override
            public void onSuccessFromSer(int rtnCode, String rtnMsg, String data) {
                if(null != mUploadNetworkListener){
                    mUploadNetworkListener.onSuccess(200, mInter);
                }
            }

            @Override
            public void onErrorFromSer(int rtnCode, String rtnMsg) {
                if(null != mUploadNetworkListener){
                    mUploadNetworkListener.onFail(502, mInter);
                }
            }

            @Override
            public void onErrorFromNet(Throwable ex, boolean isOnCallback) {
                if(null != mUploadNetworkListener){
                    mUploadNetworkListener.onFail(502, mInter);
                }

            }
        });
    }

    private UploadNetworkListener mUploadNetworkListener;

    public void setUploadNetworkListener(UploadNetworkListener listener){
        mUploadNetworkListener = listener;
    }

    public interface UploadNetworkListener{
        public void onSuccess(int code, Request_Edu_inter inter);
        public void onFail(int code, Request_Edu_inter inter);
    }
}
